package com.example.blackbox.Adapter;

import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;


import androidx.annotation.NonNull;

import com.example.blackbox.R;

public class DialogAdapter extends Dialog {
    private Button yes;
    private Button no;
    private onNoOnclickListener noOnclickListener;
    private onYesOnclickListener yesOnclickListener;
    public DialogAdapter(@NonNull Context context, int themeResId) {
        super(context, themeResId);
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.item_dialog);
        setCanceledOnTouchOutside(false);
        init();
        initEvent();
    }

    public void init(){
        yes=findViewById(R.id.dialog_true);
        no=findViewById(R.id.dialog_false);
    }

    private void initEvent() {
        yes.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (yesOnclickListener != null) {
                    yesOnclickListener.onYesOnclick();
                }
            }
        });

        no.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (noOnclickListener != null) {
                    noOnclickListener.onNoClick();
                }
            }
        });
    }

    public void setNoOnclickListener(String str, onNoOnclickListener  onNoOnclickListener) {
        if (str != null) {

        }
        this.noOnclickListener = onNoOnclickListener;
    }

    public void setYesOnclickListener(String str, onYesOnclickListener yesOnclickListener) {
        if (str != null) {

        }
        this.yesOnclickListener = yesOnclickListener;
    }

    public interface onNoOnclickListener {
        public void onNoClick();
    }

    public interface onYesOnclickListener  {
        public void onYesOnclick();
    }
}
